#include "bigintptr.h"
#include "bigint.h"

BigIntPtr::BigIntPtr(BigInt * num)
{
	counter = new PtrCounter(num);
	(*counter).ptr = num;
	(*counter).qty = 1;
}
BigIntPtr::~BigIntPtr()
{
	--(*counter).qty;
	if(counter -> qty == 0)
	{
		delete counter;
	}
}
BigInt * BigIntPtr::operator ->() const
{
	return counter -> ptr;
}
BigInt & BigIntPtr::operator *() const
{
	return counter -> (*ptr);
}
//------PtrCounter-------------------------//
PtrCounter::PtrCounter(BigInt * num)
	:ptr(num),
	 qty(0)
{
}
{
}
PtrCounter::~PtrCounter()
{
	qty = 0;
	delete ptr;
}


